from django.template.defaultfilters import register


@register.filter(is_safe=False)
def id_format(value, arg):
    res = ''
    l = arg - len(str(value))
    try:
        for i in range(0, l, 1):
            res = '0' + res
        return res + str(value)
    except (ValueError, TypeError):
        print(ValueError)
